package com.googlethemebuilder;

import java.util.ArrayList;

/**
 * 
 * @author hong
 * main Theme class that holds Metadata, ConfigMap(s)
 *
 */
public class Theme {

	private Metadata metadata;
	private ArrayList<ConfigMap> configMaps = new ArrayList<ConfigMap>();
	
	/**
	 * Add ConfigMap
	 * @param configMap
	 */
	public void addConfigMap(ConfigMap configMap) {
		configMaps.add(configMap);
	}
	
	public String generateTheme() throws IncompleteMetadataException {
		if (metadata==null) {
			throw new IncompleteMetadataException();
		}
		
		StringBuilder sb = new StringBuilder();
		sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>").append("<ConfigMaps>");

		// append metadata
		sb.append(metadata.toXML());
		
		// append all the ConfigMaps
		for (ConfigMap configMap : configMaps) {
			sb.append(configMap.toXML());
		}
		
		sb.append("</ConfigMaps>");
		
		return sb.toString();
	}
	

	public Metadata getMetadata() {
		return metadata;
	}

	public void setMetadata(Metadata metadata) {
		this.metadata = metadata;
	}

	public ArrayList<ConfigMap> getConfigMaps() {
		return configMaps;
	}

	public void setConfigMaps(ArrayList<ConfigMap> configMaps) {
		this.configMaps = configMaps;
	}
}
